# -*- coding: utf-8 -*-
from sqlalchemy import Column, Integer, String, DateTime, func
import datetime

from utils.work_db import Base

# 公司规模
SIZE = {
    1: '50人以下',
    2: '50-100人',
    3: '100至499人',
    4: '500以上'
}


class Company(Base):
    __tablename__ = 'company'
    company_id = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(String, comment="单位名称", nullable=False)
    industry_id = Column(Integer, comment='行业id')
    industry_name = Column(String, comment='行业名称')
    address = Column(String)
    note = Column(String)
    manager_user = Column(String)
    tel = Column(String)
    post = Column(String)
    credentials_url = Column(String)
    credentials_name = Column(String)
    qita = Column(String)
    status = Column(Integer, default=1)
    province_code = Column(String)
    city_code = Column(String)
    country_code = Column(String)
    create_userid = Column(Integer)
    create_time = Column(DateTime, default=func.now())
    update_time = Column(DateTime, default=func.now())
    audit_time = Column(DateTime, default=func.now())
    audit_status = Column(Integer, default=0)
    audit_msg = Column(String)
    audit_userid = Column(Integer)
    c_uuid = Column(String)
    # 规模
    size = Column(Integer)
    certification = Column(Integer, default=0)

    def json(self):
        return {
            'company_id': self.company_id,
            'name': self.name,
            'industry_id': self.industry_id if self.industry_id else '',
            'industry_name': self.industry_name if self.industry_name else '',
            'address': self.address if self.address else '',
            'note': self.note if self.note else '',
            'manager_user': self.manager_user if self.manager_user else '',
            'tel': self.tel if self.tel else '',
            'post': self.post if self.post else '',
            'credentials_url': self.credentials_url if self.credentials_url else '',
            'credentials_name': self.credentials_name if self.credentials_name else '',
            'qita': self.qita if self.qita else '',
            'status': self.status,
            'province_code': self.province_code if self.province_code else '',
            'city_code': self.city_code if self.city_code else '',
            'country_code': self.country_code if self.country_code else '',
            'size': self.size,
            'certification': self.certification
        }
